#ifndef CFONTMANAGER_H
#define CFONTMANAGER_H

/**
  * @file     	cfont.h
  * @author   	MYL
  * @email   	yunlongma0@163.com
  * @version	V1.0
  * @date    	18-06-2021
  * @brief   	Font class based on FreeType
  * @details
  *     This class is responsible for loading fonts, rendering \n
  *character bitmaps, and caching loaded characters
*/

#include "cfont.h"
#include <unordered_map>
#include "CStringUtil.h"
#define CONVERT_FONT_INDEX(x) (((x) < 1 || (x) > (int)m_fonts.size()) ? -1 : (x) - 1)
using namespace std;
class CFontManager
{
public:
    CFontManager();
    ~CFontManager();

    int         initialize(const char* path);
    int         createFont(const char *filename, int face, int tall, bool bold, bool italic, bool antialias);//创建字体
    int         getFontTall(int font_index);
    void        renderChar(int font_index, int code, unsigned char* screen, Vec2i& position, Color color);
    int         getFontIndex(string name, int fontSize);
    void        setStartPosition(Vec2i pos);

private:
    FT_Library      m_library;
    vector<CFont*>  m_fonts;

    Vec2i           m_start;

    string          m_fontPath;
};

#endif 